home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 23.1 KB | 751 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWDrCmd.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWDRCMD_H
- #include "FWDrCmd.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWLNKMGR_H
- #include "FWLnkMgr.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWREGION_H
- #include "FWRegion.h"
- #endif
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODClipboard_xh
- #include <Clipbd.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODDragAndDrop_xh
- #include <DragDrp.xh>
- #endif
-
- #ifndef SOM_ODDragItemIterator_xh
- #include <DgItmIt.xh>
- #endif
-
- #ifndef _TRANSFORM_
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODLinkSpec_xh
- #include <LinkSpec.xh>
- #endif
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__DRAG__)
- #include <Drag.h>
- #endif
-
- //========================================================================================
- // Runtime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWFrameworkCommands
- #endif
-
- FW_DEFINE_CLASS_M1(FW_CDragCommand, FW_CCommand)
- FW_DEFINE_CLASS_M1(FW_CDropCommand, FW_CCommand)
-
- //========================================================================================
- // constants
- //========================================================================================
-
- //static const ODPropertyName FW_kPropFrameInfo = "Apple:ODF:Property:FrameInfo";
-
- //========================================================================================
- // FW_CDragCommand class
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CDragCommand constructor
- //----------------------------------------------------------------------------------------
-
- FW_CDragCommand::FW_CDragCommand(Environment* ev,
- FW_CFrame* frame,
- FW_Boolean canUndo) :
- FW_CCommand(ev, FW_kDragCommand, frame, canUndo),
- fDragRegion(),
- fDestPart(NULL)
- {
- fBeganTransaction = FALSE;
- fDragResult = kODDropFail;
-
- if (canUndo)
- {
- fActionType = kODEndAction;
- // Set menu strings here so that we don't pass NULL strings to OpenDoc when AddAction is called
- this->SetMenuStrings(ev, "Undo Drag-Move", "Redo Drag-Move");
- }
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDragCommand destructor
- //----------------------------------------------------------------------------------------
-
- FW_CDragCommand::~FW_CDragCommand()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDragCommand::DoIt
- //----------------------------------------------------------------------------------------
-
- void FW_CDragCommand::DoIt(Environment* ev) // Override
- {
- this->DragCompleted(ev);
-
- if (fCanUndo)
- this->SaveRedoState(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDragCommand::CommitDone
- //----------------------------------------------------------------------------------------
-
- void FW_CDragCommand::CommitDone(Environment* ev)
- {
- if (fCanUndo)
- if (this->HasAddedAction(ev) && this->IsDragMoveToAnotherPart(ev))
- this->FreeUndoState(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDragCommand::BeginDrag
- //----------------------------------------------------------------------------------------
-
- void FW_CDragCommand::BeginDrag(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- ODPart* destPart;
- ODID frameID;
- ODDragAndDrop* drag;
- ODStorageUnit* dragSU;
-
- ODFacet* facet = theMouseEvent.GetFacet(ev);
-
- // ----- In the following block we focus on the window -----
- {
- FW_CWindowContext wc(ev, facet);
-
- FW_CRect selectionBounds; // selectionBounds is in content coordinate
-
- // ----- Scope for aqDragShape and aqWindowContentTransform -----
- {
- FW_CAcquiredODShape aqDragShape(this->CreateDragShape(ev, facet));
- selectionBounds = FW_GetShapeBoundingBox(ev, aqDragShape);
-
- FW_CAcquiredODTransform aqWindowContentTransform = facet->AcquireWindowContentTransform(ev, NULL);
- aqDragShape->Transform(ev, aqWindowContentTransform);
-
- fDragRegion = ::FW_CopyRegion(::FW_GetShapeRegion(ev, aqDragShape));
- }
-
- #ifdef FW_BUILD_MAC
- // ----- fDragRegion must be in screen coordinate on the Mac
- Point localToGlobal = {FW_QDGlobals.thePort->portRect.top, FW_QDGlobals.thePort->portRect.left};
- ::LocalToGlobal(&localToGlobal);
- FW_CPoint offset(localToGlobal);
- ::FW_OffsetRegion(fDragRegion, offset.x, offset.y);
- #endif
-
- // ----- Fill Drag and Drop SU with Props n' Vals
- drag = fPart->GetSession(ev)->GetDragAndDrop(ev);
- drag->Clear(ev);
- dragSU = drag->GetContentStorageUnit(ev);
-
- // ----- write out the contents of the drag
- fSelection->ExternalizeData(ev, fFrame, FW_kDragAndDropStorage, dragSU, kODCloneCut);
-
- /*
- [HLX] I am not sure why I have to do that?
- // ----- save ID of frame being dragged
- frameID = fFrame->GetID(ev);
- dragSU->AddProperty(ev, FW_kPropFrameInfo)->AddValue(ev, kODULong);
-
- FW_CByteArray byteArray(&frameID, sizeof(ODID));
- dragSU->SetValue(ev, byteArray);
- */
- // ----- save offset between mousedown pt and topLeft pt of selection
- // (must convert to Content coordinates first)
- FW_CPoint mouseOffset = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- frame->GetContentView(ev)->FrameToViewContent(ev, mouseOffset);
-
- mouseOffset -= selectionBounds.TopLeft();
-
- dragSU->AddProperty(ev, kODPropMouseDownOffset)->AddValue(ev, kODPoint);
-
- FW_CByteArray byteArray(&mouseOffset, sizeof(FW_CPoint));
- dragSU->SetValue(ev, byteArray);
-
- // ----- Write out Link Spec if possible -----
- if (theMouseEvent.IsItemModifier(ev) && !fPart->IsReadOnly(ev)) // command key is down
- {
- FW_CLinkManager* linkMgr = fPart->GetLinkManager(ev);
- if (linkMgr && fSelection->IsSelectionPublishable(ev))
- {
- ODLinkSpec* linkSpec = NULL;
- FW_VOLATILE(linkSpec);
- ODUpdateID updateID = fPart->GetSession(ev)->UniqueUpdateID(ev); // need data to put in the link spec
- FW_CByteArray data(&updateID, sizeof(updateID));
-
- FW_TRY
- {
- linkSpec = fPart->GetStorageUnit(ev)->GetDraft(ev)->CreateLinkSpec(ev, fPart->GetODPart(ev), data);
- dragSU->AddProperty(ev, kODPropLinkSpec);
- linkSpec->WriteLinkSpec(ev, dragSU);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- // exception occurred - just continue without the link spec
- if (linkSpec)
- {
- delete linkSpec;
- linkSpec = NULL;
- }
- // FW_THROW_SAME();
- }
- FW_CATCH_END
-
- if (linkSpec)
- {
- // Create a publisher
- FW_CPublishLink* publishLink = linkMgr->NewPublishLink(ev, updateID, fFrame->GetPresentation(ev));
- linkMgr->SetPendingDropLink(ev, publishLink);
- delete linkSpec;
- }
- }
- }
-
- fPart->Dragging(ev, fFrame, TRUE);
- if (fCanUndo) // post an empty Begin action
- {
- ODUndo* undo = fPart->GetSession(ev)->GetUndo(ev);
- undo->MarkActionHistory(ev); // in case operation fails and we need to roll back transactions
- this->AddAction(ev, kODBeginAction, NULL, 0, fUndoString, fRedoString);
- fBeganTransaction = TRUE;
- }
-
- FW_CMouseEvent dragEvent(ev, theMouseEvent);
- ODEventData* eventData = dragEvent.GetPlatformEvent();
- FW_CByteArray dragRegionBArray(&fDragRegion, sizeof(fDragRegion));
- FW_CByteArray dragEventBArray(&eventData, sizeof(ODEventData*));
-
- fDragResult = drag->StartDrag(ev, fFrame->GetODFrame(ev), kODDragImageRegionHandle, dragRegionBArray, &destPart, dragEventBArray);
-
- fDestPart = destPart;
- if (!this->IsDragMoveToAnotherPart(ev)) // can only Undo drag-move to another part
- fCanUndo = FALSE;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDragCommand::IsDragMoveToAnotherPart
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CDragCommand::IsDragMoveToAnotherPart(Environment* ev)
- {
- return (fDragResult == kODDropMove && fDestPart != fPart->GetODPart(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDragCommand::DragCompleted
- //----------------------------------------------------------------------------------------
-
- void FW_CDragCommand::DragCompleted(Environment* ev)
- {
- if (this->IsDragMoveToAnotherPart(ev)) // it's a move to another part
- {
- if (fCanUndo)
- this->SaveUndoState(ev);
-
- if (!fSelection->ClearSelection(ev))
- fDragResult = kODDropFail;
- }
-
- if (fDestPart)
- {
- fDestPart->Release(ev);
- fDestPart = NULL;
- }
-
- fPart->Dragging(ev, fFrame, FALSE);
-
- ::FW_DisposeRegion(fDragRegion);
-
- this->AdjustUndo(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDragCommand::CreateDragShape
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CDragCommand::CreateDragShape(Environment* ev, ODFacet* facet)
- {
- return fSelection->CreateSelectionOutline(ev, facet, fFrame);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDragCommand::AdjustUndo
- //----------------------------------------------------------------------------------------
-
- void FW_CDragCommand::AdjustUndo(Environment* ev)
- {
- // Check for failure, and if so clean up
- if (fDragResult == kODDropFail) // Drag&Drop operation failed somewhere along the line
- {
- fCausesChange = FALSE; // Don't call part->Changed()
- if (fCanUndo) // cancel the Undo!
- {
- this->FreeUndoState(ev); // Discard any data saved for Undo
- fCanUndo = FALSE;
- }
-
- if (fBeganTransaction) // we've already added a Begin action
- {
- this->AbortTransaction(ev); // clear unfinished transactions from Undo stack
- fBeganTransaction = FALSE;
- }
- }
- else if (fBeganTransaction && !fCanUndo) // fCanUndo was turned off after BeginAction was added
- {
- // add an EndAction to finish the transaction, since PerformCommand won't
- this->AddAction(ev, kODEndAction, NULL, 0, fUndoString, fRedoString);
- fBeganTransaction = FALSE;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDragCommand::AbortTransaction
- //----------------------------------------------------------------------------------------
-
- void FW_CDragCommand::AbortTransaction(Environment* ev)
- {
- // First add a bogus End action so the Undo object doesn't think it's in the middle of a transaction
- this->AddAction(ev, kODEndAction, NULL, 0, fUndoString, fRedoString);
-
- // Now clear the Undo stack back to our mark, which is just before the Begin action
- ODUndo* undo = fPart->GetSession(ev)->GetUndo(ev);
- undo->ClearActionHistory(ev, kODRespectMarks);
- }
-
- //========================================================================================
- // FW_CDropCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand constructor
- //----------------------------------------------------------------------------------------
-
- FW_CDropCommand::FW_CDropCommand(Environment* ev,
- FW_CPart* itsPart,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- const FW_CPoint& dropPoint,
- FW_Boolean canUndo) :
- FW_CCommand(ev, FW_kDropCommand, frame , canUndo),
- fDropItemIterator(dropInfo),
- fFacet(facet),
- fDropPoint(dropPoint)
- {
- fDroppedInSameFrame = FALSE;
- fDropResult = kODDropFail;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand destructor
- //----------------------------------------------------------------------------------------
-
- FW_CDropCommand::~FW_CDropCommand()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand::DoIt
- //----------------------------------------------------------------------------------------
-
- FW_DECLARE_THROW_POINT(FW_CDropCommand_DoIt_BeforeHandleDrop);
- FW_DECLARE_THROW_POINT(FW_CDropCommand_DoIt_AfterHandleDrop);
-
- void FW_CDropCommand::DoIt(Environment* ev) // Override
- {
- if (!fFrame->GetCanAcceptDrop(ev))
- fDropResult = kODDropFail;
- else
- {
- if (fCanUndo)
- this->SaveUndoState(ev);
- FW_TRY {
- FW_CHECK_THROW_POINT (FW_CDropCommand_DoIt_BeforeHandleDrop);
- fDropResult = this->HandleDrop(ev);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- if (fCanUndo)
- FreeUndoState (ev);
- FW_THROW_SAME ();
- }
- FW_CATCH_END
- }
- FW_CHECK_THROW_POINT (FW_CDropCommand_DoIt_AfterHandleDrop);
- this->AdjustUndo(ev); // won't fail
-
- // Now that we've successfully dropped, "protect" it by supressing any subsequent
- // failures. We *don't* rethrow now because undo is less important.
-
- if (fCanUndo) {
- FW_TRY {
- this->SaveRedoState(ev);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- // Having already called HandleDrop and performed the major work of this
- // command we *really* want to avoid passing exceptions up. It would be nice
- // if we could put up an alert saying that Redo won't be supported, though.
- }
- FW_CATCH_END
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand::AdjustUndo
- //----------------------------------------------------------------------------------------
-
- void FW_CDropCommand::AdjustUndo(Environment* ev)
- {
- if (fDropResult == kODDropFail) // Drop failed--can't Undo
- {
- if (fCanUndo)
- this->FreeUndoState(ev); // Discard any data saved for Undo
- fCanUndo = FALSE; // Don't call AddActionToHistory
- fCausesChange = FALSE; // Don't call fPart->Changed()
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand::CommitUndone
- //----------------------------------------------------------------------------------------
-
- void FW_CDropCommand::CommitUndone(Environment* ev)
- {
- if (fCanUndo)
- if (!this->IsDragMoveInSameFrame(ev))
- this->FreeRedoState(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand::DoDrop
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CDropCommand::DoDrop( Environment* ev,
- ODStorageUnit* dropSU,
- const FW_CPoint& mouseOffset,
- const FW_CPoint& dropPoint,
- FW_Boolean isDropMove)
- {
- FW_UNUSED(mouseOffset);
- FW_UNUSED(dropPoint);
-
- ODCloneKind cloneKind = (isDropMove ? kODCloneDropMove : kODCloneDropCopy);
-
- FW_Boolean result = FALSE;
- FW_TRY
- {
- result = fSelection->InternalizeData(ev, fFrame, dropSU, cloneKind) != FW_kInternalizeFailed;
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- FW_THROW_SAME();
- }
- FW_CATCH_END
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand::DoDroppedInSameFrame
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CDropCommand::DoDroppedInSameFrame(Environment* ev,
- ODStorageUnit* dropSU,
- const FW_CPoint& originPoint,
- const FW_CPoint& dropPoint)
- {
- FW_UNUSED(dropSU);
- FW_UNUSED(originPoint);
- FW_UNUSED(dropPoint);
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand::GetDropOrigin
- //----------------------------------------------------------------------------------------
-
- void FW_CDropCommand::GetDropOrigin(Environment* ev, FW_CPoint& originPoint)
- {
- // ----- Calculate originPoint (in content coordinate)
- FW_SPlatformPoint dragOrigin;
-
- ODDragAndDrop* drag = fPart->GetSession(ev)->GetDragAndDrop(ev);
-
- #ifdef FW_BUILD_MAC
- DragReference theDrag = drag->GetDragReference(ev);
- ::GetDragOrigin(theDrag, &dragOrigin);
- ::GlobalToLocal(&dragOrigin);
- #endif
- #ifdef FW_BUILD_WIN
- dragOrigin = drag->GetDragOrigin(ev);
- FW_CAcquiredODWindow aqODWindow = fFacet->AcquireWindow(ev);
- ::ScreenToClient(aqODWindow->GetPlatformWindow(ev), &dragOrigin);
- #endif
-
- originPoint = dragOrigin;
-
- FW_CAcquiredODTransform aqWindowContentTransform = fFacet->AcquireWindowContentTransform(ev, NULL);
- originPoint.InverseTransform(ev, aqWindowContentTransform);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand::HandleDrop
- //----------------------------------------------------------------------------------------
-
- FW_DECLARE_THROW_POINT (FW_CDropCommand_HandleDrop_AfterFirstDrop);
-
- ODDropResult FW_CDropCommand::HandleDrop(Environment* ev)
- {
- ODStorageUnit *dropSU;
- FW_CPoint originPoint, dropPoint;
- ODDropResult dropResult = kODDropFail; // assume the worst
- FW_Boolean acceptedDrop = FALSE;
- FW_Boolean handledDrop = FALSE;
-
- ODDragAndDrop* drag = fPart->GetSession(ev)->GetDragAndDrop(ev);
-
- this->GetDropOrigin(ev, originPoint);
- unsigned long attributes = drag->GetDragAttributes(ev);
- FW_Boolean isDropMove = (attributes & kODDropIsMove);
-
- if ((attributes & kODDropIsPasteAs) && fFrame->GetWindow(ev)->IsActive(ev)) // check that the window is in the foreground
- {
- FW_Boolean createdLink = FALSE;
- dropSU = fDropItemIterator->First(ev);
- acceptedDrop = this->HandlePasteAsDialog(ev, dropSU, handledDrop, createdLink);
- if (handledDrop && acceptedDrop)
- {
- fCommandID = kODCommandPasteAs;
- this->DoDroppedPasteAs(ev, originPoint, fDropPoint);
- }
- if (createdLink) // If the drop created a link, return kODDropCopy regardless of the drop attributes.
- return kODDropCopy;
- }
-
- if (!handledDrop)
- {
- /* Regarding exception handling...
- What happens if we are dropping several items and the first goes Ok but a later
- one causes an exception to be thrown? Should be try to undo the previous drops
- or just exit (not having fully cleaned up)? We are not going to clean up, on
- the theory that you probably want dropped objects to stick around. If whoever
- called us assumes that we are going to either completely succeed or completely
- fail (i.e. not exit with a partial state change) then there may be a problem.
- This situation comes up every time we have a loop with a state change in it.
- */
- // ----- Iterate thru dropped items
- for (dropSU = fDropItemIterator->First(ev); dropSU && !acceptedDrop;
- dropSU = fDropItemIterator->Next(ev))
- {
- if ((attributes & kODDragIsInSourceFrame) && isDropMove)
- {
- acceptedDrop = this->DoDroppedInSameFrame(ev, dropSU, originPoint, fDropPoint);
- fPart->DeletePromise(ev, FW_kDragAndDropStorage);
- fDroppedInSameFrame = TRUE;
- }
- else
- {
- FW_CPoint mouseDownOffset;
- if (dropSU->Exists(ev, kODPropMouseDownOffset, kODPoint, 0))
- {
- dropSU->Focus(ev, kODPropMouseDownOffset, kODPosUndefined, kODPoint, 0, kODPosFirstSib);
- FW_CByteArray byteArray;
- dropSU->GetValue(ev, sizeof(FW_CPoint), byteArray);
- byteArray.CopyBuffer(&mouseDownOffset, sizeof(FW_CPoint));
- }
-
- ODWindow* window = fFacet->GetWindow(ev);
- if (!window->IsActive(ev))
- window->Select(ev);
-
- ODFrame* odFrame = fFacet->GetFrame(ev);
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
- frame->ActivateFrame(ev, fFacet);
-
- acceptedDrop = this->DoDrop(ev, dropSU, mouseDownOffset, fDropPoint, isDropMove);
- }
- FW_CHECK_THROW_POINT (FW_CDropCommand_HandleDrop_AfterFirstDrop);
- }
- }
-
- // ----- Return drop result
- if (acceptedDrop)
- dropResult = (isDropMove ? kODDropMove : kODDropCopy);
-
- return dropResult;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand::HandlePasteAsDialog
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CDropCommand::HandlePasteAsDialog(Environment* ev, ODStorageUnit* dropSU,
- FW_Boolean& handledDrop, FW_Boolean& createdLink)
- {
- FW_Boolean result = FALSE;
- ODPasteAsMergeSetting mergeSetting;
- ODBoolean canPasteLink = FALSE;
- FW_CLinkManager* linkMgr = fPart->GetLinkManager(ev);
- ODPasteAsResult pasteAsResult;
-
- // ---- Check whether the selection supports linking ----
- if (linkMgr && fSelection->CanSubscribe(ev, mergeSetting))
- {
- /* if (dropSU->Exists(ev, kODPropLinkSpec, (ODValueType)NULL, 0)) [MEB] OpenDoc does this */
- canPasteLink = TRUE;
- }
-
- // ---- Display the Paste As... dialog ----
- ODDragAndDrop* drag = fPart->GetSession(ev)->GetDragAndDrop(ev);
- result = drag->ShowPasteAsDialog(ev, canPasteLink, mergeSetting,
- fFrame->GetActiveFacet(ev), // facet from which dialog is triggered
- fFrame->GetViewType(ev), // viewType of data
- dropSU, &pasteAsResult);
-
- if (result == kODFalse)
- handledDrop = TRUE; // we tried, but the user cancelled
- else
- {
- // --- Figure out what to do depending on settings from Paste As dialog
- if (pasteAsResult.pasteLinkSetting == kODTrue) // user wants to create a Link
- {
- result = linkMgr->PasteWithLink(ev, dropSU, pasteAsResult, fFrame->GetPresentation(ev));
- if (result)
- createdLink = TRUE; // let the caller know that a link was created
- handledDrop = TRUE;
- }
- else if (pasteAsResult.mergeSetting == kODFalse) // user wants to embed a Part w/o Linking
- {
- result = this->DoPasteAsEmbed(ev, dropSU);
- handledDrop = TRUE;
- }
- else // Merge with Contents - let Drag&Drop command handle this
- handledDrop = FALSE;
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand::DoDroppedPasteAs
- //----------------------------------------------------------------------------------------
- void FW_CDropCommand::DoDroppedPasteAs(Environment* ev,
- const FW_CPoint& originPoint,
- const FW_CPoint& dropPoint)
- {
- FW_UNUSED(originPoint);
- FW_UNUSED(dropPoint);
-
- // Override to perform post-Drop positioning on the items that were dropped
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDropCommand::DoPasteAsEmbed
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CDropCommand::DoPasteAsEmbed(Environment* ev, ODStorageUnit* storageUnit)
- {
- FW_UNUSED(storageUnit);
-
- // Override to paste the contents of the storageUnit as an embedded part (no linking)
- return FALSE;
- }
-
-